
export  const createStore = (reducer, applyMiddlewares) => {
    let currentState = undefined
    const listeners = []

    if (applyMiddlewares && Array.isArray(applyMiddlewares)) return

    const dispatch = action => {
        currentState = reducer(currentState, action)
        listeners.forEach(f => f())
        return action
    }

    const getState  = () => currentState

    const subscribe = handle => {
        listeners.push(handle)
    }

    dispatch({
        type: '$$_init_state_action'
    })

    return {
        dispatch,
        getState,
        subscribe
    }
}
